﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace MainSystemForm
{
    public class SystemConfig
    {
        //数据库Ip地址
        public string DbIP{set;get;} 
        //数据库用户名
        public string DbLoginName{set;get;} 
        //数据库密码
        public string DbPassword{set;get;} 
        //入口摄像头IP地址
        public string InCameraIP{set;get;} 
        //入口摄像头端口
        public string InCameraPort{set;get;} 
        //入口摄像头登录名
        public string InCameraLoginName{set;get;} 
        //入口摄像头登录密码
        public string InCameraPassword{set;get;}
        //出口摄像头IP地址
        public string OutCameraIP{set;get;}
        //出口摄像头端口
        public string OutCameraPort{set;get;}
        //出口摄像头登录名
        public string OutCameraLoginName{set;get;}
        //出口摄像头登录密码
        public string OutCameraPassword{set;get;} 
        //出入口位置
        public string PassPlace{set;get;} 
        //驶入语音提示
        public string IsPassInVoice{set;get;} 
        //驶入语音提示内容
        public string PassInVoiceText{set;get;} 
        //驶出语音提示
        public string IsPassOutVoice{set;get;} 
        //驶出语音提示内容
        public string PassOutVoiceText{set;get;} 

        //继电器IP地址
        public string RelayIP{set;get;} 
        //继电器端口
        public string RelayPort{set;get;} 
        //道闸开关状态信号
        public string GateStatus{set;get;} 
        //入口地感线圈状态信号
        public string InInductionCoilStatus{set;get;} 
        //出口地感线圈状态信号
        public string OutInductionCoilStatus{set;get;} 
        //道闸开关控制信号
        public string GateSwitch{set;get;} 
        //报警器控制信号
        public string WarnSwitch{set;get;} 
        //入口信号灯开关信号
        public string InLightSwitch{set;get;} 
        //出口信号灯开关信号
        public string OutLightSwitch{set;get;} 

        //驶入图片保存地址
        public string InPicturePath{set;get;} 
        //驶出图片保存地址
        public string OutPicturePath{set;get;} 
        //报警文件地址
        public string WarnFilePath{set;get;}

        public SystemConfig()
        {
           if (File.Exists(System.Environment.CurrentDirectory + "/system.ini"))
           {
                WinAPI winAPI = new WinAPI(System.Environment.CurrentDirectory + "/system.ini");
                DbIP = winAPI.ReadValue("DeviceConf", "DbIP");
                DbLoginName = winAPI.ReadValue("DeviceConf", "DbLoginName");
                DbPassword = winAPI.ReadValue("DeviceConf", "DbPassword");

                InCameraIP = winAPI.ReadValue("DeviceConf", "InCameraIP");
                InCameraPort = winAPI.ReadValue("DeviceConf", "InCameraPort");
                InCameraLoginName = winAPI.ReadValue("DeviceConf", "InCameraLoginName");
                InCameraPassword = winAPI.ReadValue("DeviceConf", "InCameraPassword");
                OutCameraIP = winAPI.ReadValue("DeviceConf", "OutCameraIP");
                OutCameraPort = winAPI.ReadValue("DeviceConf", "OutCameraPort");
                OutCameraLoginName = winAPI.ReadValue("DeviceConf", "OutCameraLoginName");
                OutCameraPassword = winAPI.ReadValue("DeviceConf", "OutCameraPassword");

                PassPlace = winAPI.ReadValue("DeviceConf", "PassPlace");
                IsPassInVoice = winAPI.ReadValue("DeviceConf", "IsPassInVoice");
                PassInVoiceText = winAPI.ReadValue("DeviceConf", "PassInVoiceText");
                IsPassOutVoice = winAPI.ReadValue("DeviceConf", "IsPassOutVoice");
                PassOutVoiceText = winAPI.ReadValue("DeviceConf", "PassOutVoiceText");

                InPicturePath = winAPI.ReadValue("FilePath", "InPicturePath");
                OutPicturePath = winAPI.ReadValue("FilePath", "OutPicturePath");
                WarnFilePath = winAPI.ReadValue("FilePath", "WarnFilePath");

                //继电器与网络接口
                RelayIP = winAPI.ReadValue("RelayConf", "RelayIP");
                RelayPort = winAPI.ReadValue("RelayConf", "RelayPort");
                GateStatus = winAPI.ReadValue("RelayConf", "GateStatus");
                InInductionCoilStatus = winAPI.ReadValue("RelayConf", "InInductionCoilStatus");
                OutInductionCoilStatus = winAPI.ReadValue("RelayConf", "OutInductionCoilStatus");
                GateSwitch = winAPI.ReadValue("RelayConf", "GateSwitch");
                WarnSwitch = winAPI.ReadValue("RelayConf", "WarnSwitch");
                InLightSwitch = winAPI.ReadValue("RelayConf", "InLightSwitch");
                OutLightSwitch = winAPI.ReadValue("RelayConf", "OutLightSwitch");
           }
           else
           {
                //throw new Exception("系统配置文件不存在！");
           }
        }
    }
}
